#!/bin/bash
echo "guess a number game start! "
echo "name: ZHANGSAN, id: 20240019872"
NUM1=$(( RANDOM % 100 + 1 ))
START=1
MAX=7

while [ $START -le $MAX ]; do
  read -p "$START/$MAX: Please input a num(1-100): " NUM2
  
  if [ $NUM2 -eq $NUM1 ]; then
    echo "Congratulations! You guessed the correct number $NUM1 in $START attempts!"
    exit 0
  elif [ $NUM2 -lt $NUM1 ]; then
    echo "Too small! Try a larger number."
  else
    echo "Too big! Try a smaller number."
  fi
  
  START=$(( START + 1 ))
done
echo "Game over! You've used all $MAX attempts. The correct number was $NUM1."